import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Lobster here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Lobster extends Actor
{
    /**
     * Act - do whatever the Lobster wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        move(3);
        turnAtEdge();
        randomTurn();
        LobsterEat();
        // Add your action code here.
    }
    public void turnAtEdge()
    {
        if(isAtEdge())
        {
            turn(15);
        }
    }
    public void randomTurn()
    {
        if(Greenfoot.getRandomNumber(100)<=30)
        {
            turn(Greenfoot.getRandomNumber(60)-30);
        }
    }
    public void LobsterEat()
    {
        if(isTouching(Crab.class))
        {
            removeTouching(Crab.class);
            Greenfoot.playSound("au.wav");
        }
    }
}
